﻿using System.Globalization;
using System.Windows.Data;

namespace PMIS.Common.Converter
{
    public class IntToBoolConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var paramValue = int.Parse(parameter.ToString());
            if (value is int intValue)
            {
                return intValue == paramValue;
            }
            return false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var paramValue = int.Parse(parameter.ToString());
            if (value is bool isChecked && isChecked)
            {
                return paramValue;
            }
            return Binding.DoNothing;
        }
    }
}
